package com.example.demo.service;

import com.example.demo.mapper.CarMapper;
import com.example.demo.mapper.MessageMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Service
public class CarChangeService {
    @Resource
    CarMapper carMapper;
    @Resource
    MessageMapper messageMapper;
    @Transactional
    public void carChange(int message_id,int car_id){
        //carMapper.lock(car_id);
        carMapper.changeStatus(5,car_id);
        carMapper.delIndustry(car_id);
        carMapper.releaseCar(car_id);
        carPosition_change(message_id,car_id);
    }

    public void carPosition_change(int message_id,int car_id){
        int end_id = messageMapper.select_end(message_id);
        carMapper.changeCarPosition(car_id,end_id);
    }
}
